package com.ccys.common.third.sms;


import com.ccys.common.util.StringUtil;
import com.nexmo.client.NexmoClient;
import com.nexmo.client.NexmoClientException;
import com.nexmo.client.sms.MessageStatus;
import com.nexmo.client.sms.SmsSubmissionResponse;
import com.nexmo.client.sms.messages.TextMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * Nexmo 短信
 * @author Administrator
 *
 * 参考地址 ：https://www.nexmo.com
 */
@Slf4j
@Component
@SuppressWarnings("unchecked")
@DependsOn("smsConstants")
public class SmsUtil {



       /**
        * @description 发送 nexmo 短信
        * @param dto phone 电话号码，dial 区号，content 内容，type 短信提供商类型 (nexmo,dome) 默认 nexmo
        * 调用示例 ：SmsUtil.sendSmsContent(new SmsDto(null,tblCountry.getDial(),dto.getPhone(),code));
        * @return boolean fale 失败，true 成功
        * @date     2024/1/30
        * @author   cloud fly
        */
    public static boolean sendSmsContent(SmsDto dto) {
        String phone = dto.getPhone();
        String content = dto.getContent();
        String dial = dto.getDial();
        String type = dto.getType();
        boolean flag ;
        if("dome".equals(type)) {
            flag = DomeSms.sendSmsContent(phone,content,dial);
        }else{
            flag = NexmoSms.sendSmsContent(phone,content,dial);
        }
        return flag;
    }

}
